import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: lv
 * Date: 2023-03-17
 * Time: 17:45
 */

class Student /*implements Comparable<Student>*/{
    private String name;
    private int age;
    private double score;



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    //**/

    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}

class NameComparator implements Comparator<Student>{
    @Override
    public int compare(Student o1, Student o2) {
        return o1.getName().compareTo(o2.getName());
    }
}

class AgeComparator implements Comparator<Student>{
    @Override
    public int compare(Student o1, Student o2) {
        return o1.getAge()-o2.getAge();
    }
}

class ScoreComparator implements Comparator<Student>{
    @Override
    public int compare(Student o1, Student o2) {
        return (int)(o1.getScore()-o2.getScore());
    }
}

public class TestDemo2 {

    public static void main(String[] args) {

        /*Student[] students=new Student[]{
                new Student("c",16,66.7),
                new Student("zhangh",58,98.5),
                new Student("sgd",3,86.2),
                new Student("dfjd",35,77.8),
        };
        System.out.println(Arrays.toString(students));*/
        Student student1=new Student("c",16,66.7);
        Student student2=new Student("z",58,98.5);
        Student student3=new Student("a",3,86.2);
        Student student4=new Student("b",35,77.8);
       /* System.out.println(student1.compareTo(student2));*/
        NameComparator nameComparator=new NameComparator();
        System.out.println(nameComparator.compare(student1,student2));
        AgeComparator ageComparator=new AgeComparator();
        System.out.println(ageComparator.compare(student2, student4));
        ScoreComparator scoreComparator=new ScoreComparator();
        System.out.println(scoreComparator.compare(student2, student4));

    }
}
